package java_0401_template;

abstract class Template {//抽象类

    public abstract void job();//抽象方法

    public void calTime() {
        long start = System.currentTimeMillis();
        job();
        long end = System.currentTimeMillis();
        System.out.println("运行时间" + (end - start));
    }

}

class A extends Template {

    @Override
    public void job() {
        int sum = 0;
        for (int i = 0; i < 3000000; i++) {
            sum += i;
        }
    }
}

class B extends Template {

    @Override
    public void job() {
        int sum = 0;
        for (int i = 0; i < 2000000; i++) {
            sum += i;
        }
    }
}